package com.dlut.java4;

import java.util.*;

/**
 * @Author: LiuHeng
 * @Description:
 * @Date: 2022-09-23 20:24
 */
public class T0923_OPPO {

    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n+1];
        for (int i = 1; i <= n; i++) {
            num[i] = in.nextInt();
        }
        int[] arr1 = new int[n];
        int[] arr2 = new int[n];
        for (int i = 0; i < n - 1; i++) {
            arr1[i] = in.nextInt();
            arr2[i] = in.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (num[i] != i){
                swap(num, i, num[i]);
                count++;
                i--;
            }
        }
        System.out.println(count);
    }

    private static void swap(int[] num, int i, int j) {
        int temp = num[i];
        num[i] = num[j];
        num[j] = temp;
    }

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int c = in.nextInt();
        Map<Integer, Set<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            if (map.containsKey(x)){
                map.get(x).add(y);
            }else {
                Set<Integer> set = new HashSet<>();
                set.add(y);
                map.put(x, set);
            }
        }
        Set<Integer> ans = new HashSet<>();
        ans.add(c);
        dfs(map, ans, c);
        System.out.println(ans.size());
    }

    private static void dfs(Map<Integer, Set<Integer>> map, Set<Integer> ans, int temp) {
        if (map.get(temp) == null)
            return;
        for (int num : map.get(temp)){
            if (!ans.contains(num)){
                ans.add(num);
                dfs(map, ans, num);
            }

        }
    }


    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String sq = in.nextLine();
        int q = Integer.parseInt(sq);
label:  for (int i = 0; i < q; i++) {
            String s = in.nextLine();
            String t = in.nextLine();
            if (s.length()!= t.length()){
                System.out.println("No");
                continue;
            }
            int count = 0;
            boolean flag = true;
            for (int j = 0; j < s.length(); j++) {
                if (s.charAt(j) != t.charAt(j)){
                    if (flag && j < s.length()-1 && s.charAt(j)==t.charAt(j+1) && s.charAt(j+1)==t.charAt(j)){
                        flag = false;
                        j++;
                    }else {
                        System.out.println("No");
                        continue label;
                    }
                }
            }
            System.out.println("Yes");
        }
    }
}
